function [X2, L, rho2] = powermethodRHO(A, X2, maxit)
%
%  Same as POWERMETHOD but returns estimate of dominance ratio.   
%  Optionally uses aitken to accelerate rho
rho0 = 0; 
rho1 = 0;
rho2 = -555;
rho2s = 0;
rho2a = 0;
aitken_on = 1;
R2 = ones(length(X2),0);
X1 = ones(length(X2),0);
X1 = X1/norm(X1);
for iter = 1:maxit 
    % save
    R1 = R2;
    X0 = X1;
    X1 = X2;
    rho0 = rho1;
    rho1 = rho2;
    % compute
    Z       = A * X1; 
    L       = (Z'*X1); %norm(Z, 2);
    X2      = Z / norm(Z);
    R2      = X2 - X1;
    rho2s   = norm(R2,Inf) / norm(R1,Inf);
    rho2    = rho2s;
    if ( iter > 3 ) % compute Aitken anyway for printing
        rho2a  = aitken(rho0,rho1,rho2s);
    end
  %  disp(sprintf(' Rho Aitken: %10.8e and Rho: %10.8e ', rho2a, rho2s));
end
if (aitken_on == 1 && maxit > 3)
    rho2 = rho2a;
end
%rho2 =0.994034738437805;
%disp(sprintf(' Rho Aitken: %10.8e and Rho: %10.8e ', rho2a, rho2s));
end
